package com.yelp.v2;

import java.util.ArrayList;

public class TimeInterval {
	int startTime; 
	int endTime;
	ArrayList<String> priorities = new ArrayList<String>(); 
	
	public int getStartTime() {
		return startTime;
	}
	public int getEndTime() {
		return endTime;
	}
	public void setStartTime(int startTime) {
		this.startTime = startTime;
	}
	public void setEndTime(int endTime) {
		this.endTime = endTime;
	}
	public boolean isValid(int timeNow) {
		if (timeNow < endTime && timeNow >= startTime) {
			return true; 
		} else {
			return false; 
		}
	}
	public void setPriorities(String priorityString) {
		for (String eventName : priorityString.split(":")) {
			priorities.add(eventName); 
		} 
	}
	public String popEvent() {
		if (priorities.size() == 0) {
			return null; 
		}
		String tempPrior = priorities.get(0); 
		priorities.remove(0); 
		return tempPrior; 
	}
	public void pushEvent(String event) {
		priorities.add(event);
		return; 
	}
	public TimeInterval(int startHour, int endHour) {
		this.setStartTime(startHour);
		this.setEndTime(endHour);
	}
	public TimeInterval(int startHour, int endHour, String priorityString) {
		this.setStartTime(startHour);
		this.setEndTime(endHour);
		this.setPriorities(priorityString); 
	}
}